package com.liujit.standard.basis.core.util;

import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.beanutils.BeanUtils;

import java.util.Map;

public class BeanUtil {
    private Object map2obj(Map<String,Object> map, Class<?> beanClass) throws Exception{
        if (map == null) {
            return null;
        }else {
            Object obj = beanClass.newInstance();
            BeanUtils.populate(obj, map);
            return obj;
        }
    }

    public static  Map obj2Map(Object obj) {
        if (obj == null) {
            return new BeanMap();
        }
        return new BeanMap(obj);
    }
}
